package com.example.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zhangs
 * @version v1.0
 * @decription Servlet 4，测试重定向
 * @date 2021/3/23 22:05
 **/
@WebServlet(urlPatterns = "/demo04")
public class Demo04 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // 重定向测试
        System.out.println("重定向测试！");
        // 重定向到站外网站，必须带协议
//        resp.sendRedirect("https://www.baidu.com");
        // 重定向到另外一个Servlet
        resp.sendRedirect("demo01");
    }
}
